package com.dd.controoler;

import com.dd.mapper.AddressMapper;
import com.dd.pojo.Address;
import com.dd.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class AddressController {
    @Autowired
    private AddressMapper addressMapper;

    @PostMapping("addAddress")
    public String addAddress(Address address, HttpServletRequest request){
      User user= (User) request.getSession().getAttribute("user");
        address.setUser_id(user.getId());
        int i = addressMapper.addAddress(address);
        return "redirect:loginDate";
    }
}
